package cn.acac.yygh.sms.controller;

import cn.acac.yygh.result.R;
import cn.acac.yygh.sms.service.SMSService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 短信服务接口
 */
@RestController
@RequestMapping("/user/SMS")
public class SMSController {

    @Autowired
    private SMSService smsService;

    /**
     * 发送短信验证码
     * @param phone
     * @return
     */
    @PostMapping("/sendSms/{phone}")
    public R sendSms(@PathVariable String phone){
        Boolean isFlag = smsService.sendSms(phone);
        if(isFlag){
            return R.ok().message("短信发送成功！");
        }
        return R.error().message("短信发送失败！");
    }
}
